package pa;

public class Computer implements IUSB
{

    @Override
    public void openDevice() {
        System.out.println("打开电脑");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭电脑");
    }

    public void usbeDevice(IUSB usb){
        usb.openDevice();

        if(usb instanceof Mouse){
            ((Mouse) usb).click();
        }else if(usb instanceof KeyBoard){
            ((KeyBoard) usb).inPut();
        }

        usb.openDevice();
    }
    
    public static void main(String[] args){
        Computer computer = new Computer();
        computer.openDevice();
        computer.usbeDevice(new Mouse());
        computer.usbeDevice(new KeyBoard());
        computer.closeDevice();

    } 
}
